home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple II Magazines (PO)
/
Nibble Volume 13, No. 03 (1992-03)(MindCraft Publishing)(Side A).zip
/
Nibble Volume 13, No. 03 (1992-03)(MindCraft Publishing)(Side A).po
/
KEY.QWIK.S.txt
< prev
next >
Wrap
Text File
|
1996-12-24
|
13KB
|
453 lines
; Key Qwik
; by Jerry Edens
;
; Copyright (C) 1992 by
; MindCraft Publishing Corp.
; Lincoln, MA 01773
;
; Orca/M v4.1 Assembler
;
Global data
Zero Gequ $00
One Gequ $01
LOC0 Gequ $02
LOC1 Gequ $03
LOC2 Gequ $04
LOC3 Gequ $05
Math_Reg1 Gequ $06
Math_Reg2 Gequ $07
Math_Reg3 Gequ $08
Math_Reg4 Gequ $09
Ch Gequ $24 ; Horzontal position of cursor <40 col>
basl Gequ $28 ; LOB, address of line cursor is on.
bash Gequ $29 ; HOB ^^^^^^^^
Inst_len Gequ $2F ; Instruction length.
Prompt Gequ $33 ; Prompt character storage
A1L Gequ $3C ; A1 start address for move
A1H Gequ $3D
A2L Gequ $3E ; A2 end address for move
A2H Gequ $3F
A4L Gequ $42 ; A4 destnation address for move.
A4H Gequ $43
TempY Gequ $58
Return Gequ $8D
I_Buf Gequ $0200 ; Input buffer for getln
Ourch Gequ $057B ; Cusor position horizontal in <80 col>
Wrm_Dos Gequ $BE00 ; Warm start entry point into dos.
Dos_Cmd Gequ $BE03 ; Executes the command in the input buffer.
Exter_Cmd Gequ $BE07 ; Jmp EXTRNCMD hook
Err_Out Gequ $BE09 ; Executes the BI error command handler.
State Gequ $BE42 ; >0 if deferred, else immediate mode.
Vpath1 Gequ $BE6C ; Primary pathname buffer addrress
Go_sys Gequ $BE70 ; execute dos command
S_Close Gequ $BEDD ; system level
Get_buf Gequ $BEF5 ; Get buffer # of pages in ACC.
Himem Gequ $BEFB ; High memory.
Level Gequ $BF94
Mach_id Gequ $BF98
rd80col Gequ $C01F
txtpage1 Gequ $C054
txtpage2 Gequ $C055
Eightyon Gequ $C300
Insds2 Gequ $F88E ; Monitor disasmbler
Home Gequ $FC58 ; Clear the entire screen
Rdkey Gequ $FD0C ; Get the input key.
PrByte Gequ $FDDA ; Print the byte in the acc.
Cout Gequ $FDED ; Output a character through the ksw
Move Gequ $FE2C ; Move a block of memory
Clreol Gequ $FC9C ; Clear to end of line.
end
;
;
; Relocate : This routine will relocate the program.
;
relocate start
using txt_cmd
using commands
using rest_data
msb on
lda #Zero
sta level
sta s_close+1
lda #$cc
cld
jsr go_sys
lda mach_id
lsr a
lsr a
bcc go_on
jsr eightyon
go_on jsr home
ldx #Zero ; Prints out the
loop_copy lda copyright,x ; copyright mesg.
beq copy_done
jsr cout
inx
bne loop_copy
copy_done lda exter_cmd+1
sta exter_prior+1
lda exter_cmd
sta exter_prior
lda #pages ; Set pages needed.
jsr get_buf ; Have basic.system
bcc good ; reserve the buffer
jmp err_out ; display any error
good sta himem ; new high mem
sta exter_cmd+1 ; Rest external command
sec ; Prepare for subtraction.
sbc prg_strt+1 ; start - destination.
sta math_reg1 ; Store the results.
lda prg_strt+1 ;
sta a1h
lda #Zero
sta exter_cmd
sta a1l
loop ldy #Zero ; Zero index register.
lda (a1l),y ; Get the instruction. (opcode)
beq update ; If zero then update pc.
jsr insds2 ; Disasmble the instruction.
ldy inst_len ; Get the instruction length.
cpy #$02 ; three byte instruction?
bne wrong_len ; If not the inst. doesn't have
lda (a1l),y ; a two byte address.
jsr new_address ; present add + new highmem
sta (a1l),y
wrong_len iny
tya ; Continue untill complete
jsr pc_update
jmp loop
update lda #$01 ; Add one to the pc.
jsr pc_update
update_1 ldy #$01
lda (a1l),y
beq branch_1
jsr new_address
sta (a1l),y
lda #$02
jsr pc_update
jmp update_1
branch_1 ldy #$01 ;
branch_2 lda commands,y ; update the address table.
beq out ;
clc
adc math_reg1
sta commands,y
iny
iny
bne branch_2
out ldx #Zero ;
lda prg_strt+1 ; Once addresses are updated,
stx a1l ; do the move.
sta a1h ;
ldx #<end
lda #>end
stx a2l
sta a2h
lda #Zero
sta a4l
lda himem
sta a4h
ldy #Zero
jmp move
new_address cmp prg_strt+1 ;
bcc not_ok ; See if address is within the
cmp ending+1 ; start & stop points
beq ok ; If not then leave it alone.
bcs not_ok
ok clc
adc math_reg1 ; If yes then update then
not_ok rts ; address.
pc_update clc ;
adc a1l ; Update the pc by one.
sta a1l ;
lda a1h ;
adc #Zero
sta a1h
rts
end
;
;
; Rest_Data : This is the data area for the relocate routine
;
Rest_Data data
using txt_cmd
prg_strt dc a'new_cmd'
ending dc a'end'
buf_a ds 1
amount ds 1
pages equ $03
copyright dc c'Key Qwik by Jerry Edens',h'8d'
dc c'Copyright (C) 1992, MindCraft Publ. Corp.',h'8d 8d 00'
end
;
;
; New_Cmd : This is the paraser for the input commands.
;
; Inputs : The command line pointed to by VPATH1 holds
; the command not recognized by the BI.
;
; Outputs : None
;
align 256
New_Cmd start
using txt_cmd
using commands
using rest_data
cld ; Used by BI...
lda state ; Is a basic program running.
and #$FF
beq lb1 ; If sate flag a zero no prog.
back jmp not_found
lb1 lda prompt ; Check to see if in the monitor
cmp #'*' ; if yes don't bother with
beq back
lda vpath1
sta loc0
lda vpath1+1
sta loc1
ldy #one ; Get the partial command,
loop_new lda (loc0),y ; Move it into the buffer 'Path',
beq out
ora #$80 ; set the high bit. (for B.I.)
sta path-1,y
iny
bne loop_new
;
; Check the first letter of the command to see if it is
; a posible valid command.
;
out ldx #Zero ; Zero index regs
ldy #Zero
loop_1 lda commands,x ; set up the pointer
sta loc2 ; to the command table
inx
lda commands,x
bne over ; When zero all commands
jmp not_found ; have been checked
over sta loc3
inx
lda path,y ; Get first letter of command
cmp (loc2),y ; Is it same as first letter
beq so_far_good
bcs loop_1
jmp not_found
; O.K. the first letter matched one of the commands
; now, check the rest of the command.
so_far_good iny
lda path,y
cmp #$8d
beq done
cmp (loc2),y
beq so_far_good
lda commands,x ; letter didn't match
sta loc2 ; keelp checking
inx
lda commands,x
sta loc3
inx
ldy #Zero
lda path,y
cmp (loc2),y
beq so_far_good
jmp not_found
done ldy #$01
jsr first_col ; Move the cursor to column #1
;
; Put the command on the screen as well as in the I_Buf...
;
ldy #Zero ;
loop_5 lda (loc2),y ; When command is found put it in
beq In_buff ; buffer @$200 and display it
sta I_buf,y ; on the screen
jsr cout ;
iny
bne loop_5
;
; Take additional inputs for the command.... i.e.
; filename, pathname, slot, drive, etc...
;
In_buff tya ; length of string is in Y reg.
tax ; transfer it to the X reg.
load_key jsr rdkey ;
cmp #$8D ; return we are complete
beq complete ;
cmp #$88 ; left arrow move the cursor
beq left ; left and delete previous character.
cmp #$9b ; character an esc key start all
beq esc_key ; starts you all over
cmp #$FF
beq left
cmp #$95 ; right arrow ignore it.
beq load_key ;
sta I_buf,x ; all other chacters in the buffer.
jsr cout ; Syntax is a user responsabilty.
inx
bne load_key
;
; The command has been found and has been placed in the
; input buffer at $200... Now give control to B.I...
;
complete sta I_buf,x ;
jsr Dos_cmd ; Call the BI
bcc rts ; let it do the
rts ; work.
rts jmp wrm_dos
;
; The command was not found. Give control to
; the previous External command.
;
not_found lda exter_prior+1
sta exter_jmp+2
lda exter_prior
sta exter_jmp+1
sec
exter_jmp jmp $FFFF
left bit rd80col ;
bpl fourty ; Move the cursor
dec ourch ; to the left and
lda ourch ; delete the
lsr a ; character.
tay
beq over_2
php
sei
lda #$a0
pha
bit txtpage2
bcc not_2
lda txtpage1
not_2 pla
sta (basl),y
sta txtpage1
plp
bne over_2
fourty lda #$a0
dec ch
ldy ch
beq over_3
over_2 lda #$a0
sta (basl),y
dex
over_3 jmp load_key
esc_key clc
lda #Zero
sta ch
sta ourch
jsr clreol
jmp wrm_dos
first_col sty tempy ;
ldy #$01 ; Move cursor to col #1
bit rd80col ;
bpl four
sty ourch
bne eighty
four sty ch
eighty ldy tempy
rts
re_set ldy #17
re_loop lda #Zero
sta I_buf,y
dey
bpl re_loop
rts
dc h'00 00'
end
;
;
; Commands : This is the address table for the txt
; which goes into the buffer @$200.
;
Commands data
using txt_cmd
dc a'bye'
dc a'bload'
dc a'brun'
dc a'bsave'
dc a'catalog'
dc a'close'
dc a'create'
dc a'delete'
dc a'exec'
dc a'in'
dc a'load'
dc a'lock'
dc a'pr'
dc a'prefix'
dc a'rename'
dc a'run'
dc a'save'
dc a'unlock'
dc a'verify'
dc h'00 00'
exter_prior ds 2
end
;
;
; Txt_Cmd : This is the text data for the commands.
; This is the information which is put into
; the buffer @$200. For use by the BI.
;
msb on
Txt_Cmd data
Bye dc c'BYE',h'00'
Bload dc c'BLOAD ',h'00'
Brun dc c'BRUN ',h'00'
Bsave dc c'BSAVE ',h'00'
Catalog dc c'CATALOG ',h'00'
Close dc c'CLOSE ',h'00'
Create dc c'CREATE ',h'00'
Delete dc c'DELETE ',h'00'
Exec dc c'EXEC ',h'00'
In dc c'IN#',h'00'
Load dc c'LOAD ',h'00'
Lock dc c'LOCK ',h'00'
Pr dc c'PR#',h'00'
Prefix dc c'PREFIX ',h'00'
Rename dc c'RENAME ',h'00'
Run dc c'RUN ',h'00'
Save dc c'SAVE ',h'00'
Unlock dc c'UNLOCK ',h'00'
Verify dc c'VERIFY ',h'00'
Path ds 64
end ds 1
end